package com.mengxin.secondkill.message.req;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * @author mengxin
 * @date 2020/12/24 16:33
 */
@Data
public class AddOrderReq {
    @NotNull
    @ApiModelProperty(value="商品ID")
    private Long goodsId;
    @NotNull
    @ApiModelProperty(value="ModelID")
    private Long modelId;
    @NotNull
    @ApiModelProperty(value="价格")
    private Long price;
    @Min(value = 1)
    @ApiModelProperty(value="购买数量")
    private Long sum;
    @ApiModelProperty(value="流水号")
    private Long orderNumber;

    public AddOrderReq(JSONObject jsonObject){
        this.goodsId = jsonObject.getLong("goodsId");
        this.modelId = jsonObject.getLong("modelId");
        this.price = jsonObject.getLong("price");
        this.sum = jsonObject.getLong("sum");
        this.orderNumber = jsonObject.getLong("orderNumber");
    }
}
